package com.xinyi;

/**
 * @desc:
 * @author: Shoko
 * @date: 2025/3/16
 */
public class ShapeFactory {
    public static Shape createShape(String type) throws UnsupportedShapeException {
        if (type == null) {
            throw new UnsupportedShapeException("Type cannot be null");
        }
        if (type.equalsIgnoreCase("circle")) {
            return new Circle();
        } else if (type.equalsIgnoreCase("rectangle")) {
            return new Rectangle();
        } else if (type.equalsIgnoreCase("triangle")) {
            return new Triangle();
        } else {
            throw new UnsupportedShapeException("Unsupported shape: " + type);
        }
    }
}
